package org.lovelandhs.robotics.y2010.input;

import java.util.Vector;

/**
 *
 * @author tim
 */
public class InputModel {

	private Vector buttons;
	private Vector axes;

	public InputModel() {
		buttons = new Vector();
		axes = new Vector();
	}

	public void addButton(Button button) {
		buttons.addElement(button);
	}

	public void removeButton(Button button) {
		buttons.removeElement(button);
	}

	public int buttonCount() {
		return buttons.size();
	}

	public Button getButton(int number) {
		for (int i = 0; i < buttons.size(); i++) {
			Button b = (Button) buttons.elementAt(i);

			if (b.getNumber() == number) {
				return b;
			}
		}

		return null;
	}

	public Button getButton(String name) {
		for (int i = 0; i < buttons.size(); i++) {
			Button b = (Button) buttons.elementAt(i);

			if (b.getName().equalsIgnoreCase(name)) {
				return b;
			}
		}

		return null;
	}

	public Button buttonAt(int index) {
		return (Button) buttons.elementAt(index);
	}

	public void addAxis(Axis axis) {
		axes.addElement(axis);
	}

	public void removeAxis(Axis axis) {
		axes.removeElement(axis);
	}

	public Axis getAxis(String name) {
		for (int i = 0; i < axes.size(); i++) {
			Axis a = (Axis) axes.elementAt(i);

			if (a.getName().equalsIgnoreCase(name)) {
				return a;
			}
		}

		return null;
	}

	public Axis axisAt(int index) {
		return (Axis) axes.elementAt(index);
	}

	public int axisCount() {
		return axes.size();
	}

}
